/*
 * @Author: Kingsley 
 * @Date: 2018-10-22 21:50:36 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2018-10-24 22:20:40
 * 收货地址的service实现
 */

import _axios from "@/utils/requestUtil";
import _urlConfig from "@/config/AddressURLConfig";

class Address {
  /**
   * 1.新增收货地址
   * @param {} addressData
   * {
   *  receiverName:收件人的名称
   *  receiverProvince: 收件人所在的省份
   *  receiverCity:收件人所在的城市
   *  receiverAddress:详细地址
   *  receiverPhone:收件人的手机号码
   *  receiverZip：邮政编码
   * }
   */
  addAddress(addressData) {
    return _axios.request({
      url: _urlConfig.addAddres,
      data: addressData,
      method: "post"
    });
  }

  /**
   * 2.查看收货地址列表
   * todo  分页的处理,先采用后台的默认值
   */
  addresList() {
    return _axios.request({
      url: _urlConfig.addresList,
      method: "post"
    });
  }
  /**
   * 删除收货地址
   */
  deleteAddress(shippingId){
    return _axios.request({
      url: _urlConfig.deleteAddress,
      data: {
        shippingId : shippingId
      },
      method: "post"
    });
  }

  /**
   * 
   * @param {*} addressData 
   {
   *  receiverName:收件人的名称
   *  receiverProvince: 收件人所在的省份
   *  receiverCity:收件人所在的城市
   *  receiverAddress:详细地址
   *  receiverPhone:收件人的手机号码
   *  receiverZip：邮政编码
   * }
   */
  updateAddress(addressData){
    return _axios.request({
      url: _urlConfig.updateAddress,
      data: addressData,
      method: "post"
    });
  }
}
export default Address;
